import { request } from '@/utils/request';
import { UnwrapRef } from 'vue';

/**
 * 分页查询菜单
 * @param data
 */
export function getMenuList(data: any) {
    return request.post({
        data,
        url:'/admin/menu/page',
    });
}


/**
 * 添加菜单
 */
export function addMenu(data: any) {
    return request.post({
        data,
        url: '/admin/menu/',
    });
}

/**
 * 根据id查询菜单
 */
export function getMenuById(id: number) {
    return request.get({
        url: `/admin/menu/${id}`,
    });
}

/**
 * 修改菜单
 */
export function updateMenu(data: any) {
    return request.put({
        data,
        url: '/admin/menu/',
    });
}

/**
 * 删除菜单
 */
export function deleteMenuById(ids: UnwrapRef<any[]>) {
    return request.delete({
        url: `/admin/menu/${ids}`,
    });
}

/**
 * 获取所有目录级别
 */
export function getAllLevel() {
    return request.get({
        url: '/admin/menu/tableOfContents',
    });
}

/**
 * 清除缓存
 */
export function clearCacheApi() {
    return request.get({
        url: '/admin/clearCache',
    });
}
